/**
 * @author 橘柚
 * @Date 2023/11/14 22:03
 * @Description
 */
import {createSlice, PayloadAction} from "@reduxjs/toolkit";
import {IUserInfo} from "@/api/authentication.ts";
import type {Slice} from "@reduxjs/toolkit";

export interface IUserInfoReducer {
  user: IUserInfo
}

const user: IUserInfo = {
  userId: '',
  userName: '',
  userType: '0',
  status: '0',
  nickName: '',
  avatar: '',
  email: '',
  idCard: '',
  phoneNumber: '',
  sex: '',
  loginDate: '',
  loginIp: '',
  signature: ''
}

const userInfoSlice: Slice<IUserInfoReducer> = createSlice({
  name: 'userInfo',
  initialState: {
    user
  },
  reducers: {
    setUserInfo: (state, action: PayloadAction<IUserInfo>) => {
      state.user = action.payload
    }
  }
})
export const {setUserInfo} = userInfoSlice.actions
export const userInfoReducers = userInfoSlice.reducer